// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= //
//  »Project«   Talina Gaming System (TgS) (∂)
//  »File«      TgS (XB2) Common - Math API [Vector] [U16].inl
//  »Author«    Andrew Aye (EMail: mailto:andrew.aye@gmail.com, Web: http://www.andrewaye.com)
//  »Version«   4.0
// ------------------------------------------------------------------------------------------------------------------------------ //
//  Copyright: © 2002-2010, Andrew Aye.  All Rights Reserved.
//  This software is free for non-commercial use. Redistribution and use in source and binary forms, with or without modification,
//  are permitted provided that the following conditions are met: 
//    Redistributions of source code must retain this copyright notice, this list of conditions and the following disclaimers. 
//    Redistributions in binary form must reproduce this copyright notice, this list of conditions and the following
//      disclaimers in the documentation and other materials provided with the distribution. 
//  Neither the names of the copyright owner nor the names of its contributors may be used to endorse or promote products derived
//  from this software without specific prior written permission. 
//  The intellectual property rights of the algorithms used reside with Andrew Aye.  You may not use this software, in whole or
//  in part, in support of any commercial product without the express written consent of the author.
//  There is no warranty or other guarantee of fitness of this software for any purpose. It is provided solely "as is".
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= //
#if !defined(_TGS_XB2_COMMON_MATH_API_VECTOR_U16_INL_)
#define _TGS_XB2_COMMON_MATH_API_VECTOR_U16_INL_
#pragma once


// START TGS - MATH ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

TgINLINE TgVEC_U16_08 TgMV_U16_08( const __vector4 vNative )
{
    register TgVEC_U16_08 tvResult;
    tvResult.m_mData = vNative;
    return (tvResult);
}




// -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. //
//  Bounds
// -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. //

TgINLINE TgVEC_U16_08 M_MAX<TgUINT16,8>( M_TgVEC_U16_08 tvLeft, M_TgVEC_U16_08 tvRight )
{
    return (TgMV_U16_08( __vmaxuh( tvLeft.m_mData, tvRight.m_mData ) ));
}


TgINLINE TgVEC_U16_08 M_MIN<TgUINT16,8>( M_TgVEC_U16_08 tvLeft, M_TgVEC_U16_08 tvRight )
{
    return (TgMV_U16_08( __vminuh( tvLeft.m_mData, tvRight.m_mData ) ));
}




// -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. //
//  Comparison Operators
// -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. //

TgINLINE TgVEC_U16_08 M_CMP_EQ<TgUINT16,8>( M_TgVEC_U16_08 tvLeft, M_TgVEC_U16_08 tvRight )
{
    return (TgMV_U16_08( __vcmpequh( tvLeft.m_mData, tvRight.m_mData ) ));
}


TgINLINE TgVEC_U16_08 M_CMP_NE<TgUINT16,8>( M_TgVEC_U16_08 tvLeft, M_TgVEC_U16_08 tvRight )
{
    return (TgMV_U16_08( __vxor( TgKV_FFFF.m_mData, __vcmpequh( tvLeft.m_mData, tvRight.m_mData ) ) ));
}


TgINLINE TgVEC_U16_08 M_CMP_GE<TgUINT16,8>( M_TgVEC_U16_08 tvLeft, M_TgVEC_U16_08 tvRight )
{
    return (TgMV_U16_08( __vxor( TgKV_FFFF.m_mData, __vcmpgtuh( tvRight.m_mData, tvLeft.m_mData ) ) ));
}


TgINLINE TgVEC_U16_08 M_CMP_GT<TgUINT16,8>( M_TgVEC_U16_08 tvLeft, M_TgVEC_U16_08 tvRight )
{
    return (TgMV_U16_08( __vcmpgtuh( tvLeft.m_mData, tvRight.m_mData ) ));
}


TgINLINE TgVEC_U16_08 M_CMP_LE<TgUINT16,8>( M_TgVEC_U16_08 tvLeft, M_TgVEC_U16_08 tvRight )
{
    return (TgMV_U16_08( __vxor( TgKV_FFFF.m_mData, __vcmpgtuh( tvLeft.m_mData, tvRight.m_mData ) ) ));
}


TgINLINE TgVEC_U16_08 M_CMP_LT<TgUINT16,8>( M_TgVEC_U16_08 tvLeft, M_TgVEC_U16_08 tvRight )
{
    return (TgMV_U16_08( __vcmpgtuh( tvRight.m_mData, tvLeft.m_mData ) ));
}




// -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. //
//  Arithmetic Operations
// -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. //

TgINLINE TgVEC_U16_08 M_ADD_S<TgUINT16,8>( M_TgVEC_U16_08 tvLeft, M_TgVEC_U16_08 tvRight )
{
    return (TgMV_U16_08( __vadduhs( tvLeft.m_mData, tvRight.m_mData ) ));
}


TgINLINE TgVEC_U16_08 M_ADD_M<TgUINT16,8>( M_TgVEC_U16_08 tvLeft, M_TgVEC_U16_08 tvRight )
{
    return (TgMV_U16_08( __vadduhm( tvLeft.m_mData, tvRight.m_mData ) ));
}


TgINLINE TgVEC_U16_08 M_SUB_S<TgUINT16,8>( M_TgVEC_U16_08 tvLeft, M_TgVEC_U16_08 tvRight )
{
    return (TgMV_U16_08( __vsubuhs( tvLeft.m_mData, tvRight.m_mData ) ));
}


TgINLINE TgVEC_U16_08 M_SUB_M<TgUINT16,8>( M_TgVEC_U16_08 tvLeft, M_TgVEC_U16_08 tvRight )
{
    return (TgMV_U16_08( __vsubuhm( tvLeft.m_mData, tvRight.m_mData ) ));
}


TgINLINE TgVEC_U16_08 M_AVG<TgUINT16,8>( M_TgVEC_U16_08 tvLeft, M_TgVEC_U16_08 tvRight )
{
    return (TgMV_U16_08( __vavguh( tvLeft.m_mData, tvRight.m_mData ) ));
}




// END MATH ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// END TGS /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#endif //  END  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////